.class public Lcom/netease/newsreader/download/FileDownloader;
.super Ljava/lang/Object;
.source "FileDownloader.java"


# static fields
.field private static final TAG:Ljava/lang/String; = "FileDownloader"


# instance fields
.field private block:J

.field private context:Landroid/content/Context;

.field private data:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/Integer;",
            "Ljava/lang/Long;",
            ">;"
        }
    .end annotation
.end field

.field private downloadSize:J

.field private downloadUrl:Ljava/lang/String;

.field private fileSize:J

.field private init:Z

.field private networkerr:Z

.field private notError:Z

.field private pause:Z

.field private saveFile:Ljava/io/File;

.field private threads:[Lcom/netease/newsreader/download/DownloadThread;


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;JLjava/lang/String;Ljava/lang/String;I)V
    .locals 7
    .parameter "context"
    .parameter "downloadUrl"
    .parameter "fsize"
    .parameter "dir"
    .parameter "filename"
    .parameter "threadNum"

    .prologue
    .line 91
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 28
    const-wide/16 v2, 0x0

    iput-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 30
    const-wide/16 v2, 0x0

    iput-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    .line 36
    new-instance v2, Ljava/util/concurrent/ConcurrentHashMap;

    invoke-direct {v2}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V

    iput-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    .line 42
    const/4 v2, 0x0

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    .line 44
    const/4 v2, 0x0

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->pause:Z

    .line 46
    const/4 v2, 0x0

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->networkerr:Z

    .line 48
    const/4 v2, 0x1

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->notError:Z

    .line 93
    iput-object p1, p0, Lcom/netease/newsreader/download/FileDownloader;->context:Landroid/content/Context;

    .line 94
    iput-object p2, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    .line 98
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p5}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 99
    .local v0, fileSaveDir:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_0

    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z

    .line 101
    :cond_0
    new-array v2, p7, [Lcom/netease/newsreader/download/DownloadThread;

    iput-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    .line 103
    iput-wide p3, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    .line 105
    iget-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    const-wide/16 v4, 0x0

    cmp-long v2, v2, v4

    if-gtz v2, :cond_1

    .line 106
    const/4 v2, 0x0

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    .line 135
    :goto_0
    return-void

    .line 108
    :cond_1
    new-instance v2, Ljava/io/File;

    invoke-direct {v2, v0, p6}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    iput-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->saveFile:Ljava/io/File;

    .line 119
    const/4 v1, 0x0

    .local v1, i:I
    :goto_1
    iget-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v2, v2

    if-lt v1, v2, :cond_2

    .line 123
    iget-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v4, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v4, v4

    int-to-long v4, v4

    rem-long/2addr v2, v4

    const-wide/16 v4, 0x0

    cmp-long v2, v2, v4

    if-nez v2, :cond_3

    iget-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v4, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v4, v4

    int-to-long v4, v4

    div-long/2addr v2, v4

    :goto_2
    iput-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->block:J

    .line 124
    iget-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->size()I

    move-result v2

    iget-object v3, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v3, v3

    if-ne v2, v3, :cond_5

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {p5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, p6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/netease/newsreader/util/FileUtils;->isFileExit(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_5

    .line 125
    const/4 v1, 0x0

    :goto_3
    iget-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v2, v2

    if-lt v1, v2, :cond_4

    .line 128
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "already download size "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-wide v3, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    .line 133
    :goto_4
    const/4 v2, 0x1

    iput-boolean v2, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    goto :goto_0

    .line 120
    :cond_2
    iget-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v3, v1, 0x1

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    const-wide/16 v4, 0x0

    invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v4

    invoke-interface {v2, v3, v4}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 119
    add-int/lit8 v1, v1, 0x1

    goto :goto_1

    .line 123
    :cond_3
    iget-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v4, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v4, v4

    int-to-long v4, v4

    div-long/2addr v2, v4

    const-wide/16 v4, 0x1

    add-long/2addr v2, v4

    goto :goto_2

    .line 126
    :cond_4
    iget-wide v3, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    iget-object v2, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v5, v1, 0x1

    invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    invoke-interface {v2, v5}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/Long;

    invoke-virtual {v2}, Ljava/lang/Long;->longValue()J

    move-result-wide v5

    add-long v2, v3, v5

    iput-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 125
    add-int/lit8 v1, v1, 0x1

    goto :goto_3

    .line 130
    :cond_5
    const-wide/16 v2, 0x0

    iput-wide v2, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 131
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "already download size "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-wide v3, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    goto :goto_4
.end method

.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V
    .locals 10
    .parameter "context"
    .parameter "downloadUrl"
    .parameter "dir"
    .parameter "filename"
    .parameter "threadNum"

    .prologue
    .line 143
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 28
    const-wide/16 v5, 0x0

    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 30
    const-wide/16 v5, 0x0

    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    .line 36
    new-instance v5, Ljava/util/concurrent/ConcurrentHashMap;

    invoke-direct {v5}, Ljava/util/concurrent/ConcurrentHashMap;-><init>()V

    iput-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    .line 42
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    .line 44
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->pause:Z

    .line 46
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->networkerr:Z

    .line 48
    const/4 v5, 0x1

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->notError:Z

    .line 146
    :try_start_0
    iput-object p1, p0, Lcom/netease/newsreader/download/FileDownloader;->context:Landroid/content/Context;

    .line 147
    iput-object p2, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    .line 150
    new-instance v4, Ljava/net/URL;

    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    invoke-direct {v4, v5}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 152
    .local v4, url:Ljava/net/URL;
    new-instance v2, Ljava/io/File;

    invoke-direct {v2, p3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 153
    .local v2, fileSaveDir:Ljava/io/File;
    invoke-virtual {v2}, Ljava/io/File;->exists()Z

    move-result v5

    if-nez v5, :cond_0

    invoke-virtual {v2}, Ljava/io/File;->mkdirs()Z

    .line 155
    :cond_0
    new-array v5, p5, [Lcom/netease/newsreader/download/DownloadThread;

    iput-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    .line 156
    invoke-virtual {v4}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v0

    check-cast v0, Ljava/net/HttpURLConnection;

    .line 157
    .local v0, conn:Ljava/net/HttpURLConnection;
    const/16 v5, 0x1388

    invoke-virtual {v0, v5}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V

    .line 158
    const-string v5, "GET"

    invoke-virtual {v0, v5}, Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V

    .line 159
    const-string v5, "Accept"

    const-string v6, "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"

    invoke-virtual {v0, v5, v6}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 160
    const-string v5, "Accept-Language"

    const-string v6, "zh-CN"

    invoke-virtual {v0, v5, v6}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 161
    const-string v5, "Charset"

    const-string v6, "UTF-8"

    invoke-virtual {v0, v5, v6}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 162
    const-string v5, "User-Agent"

    const-string v6, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"

    invoke-virtual {v0, v5, v6}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 163
    const-string v5, "Connection"

    const-string v6, "Keep-Alive"

    invoke-virtual {v0, v5, v6}, Ljava/net/HttpURLConnection;->setRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 164
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->connect()V

    .line 165
    invoke-static {v0}, Lcom/netease/newsreader/download/FileDownloader;->printResponseHeader(Ljava/net/HttpURLConnection;)V

    .line 166
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v5

    const/16 v6, 0xc8

    if-ne v5, v6, :cond_6

    .line 167
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getContentLength()I

    move-result v5

    int-to-long v5, v5

    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    .line 169
    iget-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    const-wide/16 v7, 0x0

    cmp-long v5, v5, v7

    if-gtz v5, :cond_1

    .line 170
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 210
    .end local v0           #conn:Ljava/net/HttpURLConnection;
    .end local v2           #fileSaveDir:Ljava/io/File;
    .end local v4           #url:Ljava/net/URL;
    :goto_0
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "init = "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-boolean v6, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    .line 211
    return-void

    .line 172
    .restart local v0       #conn:Ljava/net/HttpURLConnection;
    .restart local v2       #fileSaveDir:Ljava/io/File;
    .restart local v4       #url:Ljava/net/URL;
    :cond_1
    :try_start_1
    new-instance v5, Ljava/io/File;

    invoke-direct {v5, v2, p4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    iput-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->saveFile:Ljava/io/File;

    .line 182
    const/4 v3, 0x0

    .local v3, i:I
    :goto_1
    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v5, v5

    if-lt v3, v5, :cond_2

    .line 186
    iget-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v7, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v7, v7

    int-to-long v7, v7

    rem-long/2addr v5, v7

    const-wide/16 v7, 0x0

    cmp-long v5, v5, v7

    if-nez v5, :cond_3

    iget-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v7, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v7, v7

    int-to-long v7, v7

    div-long/2addr v5, v7

    :goto_2
    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->block:J

    .line 188
    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    invoke-interface {v5}, Ljava/util/Map;->size()I

    move-result v5

    iget-object v6, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v6, v6

    if-ne v5, v6, :cond_5

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-static {p3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v5, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/netease/newsreader/util/FileUtils;->isFileExit(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_5

    .line 189
    const/4 v3, 0x0

    :goto_3
    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v5, v5

    if-lt v3, v5, :cond_4

    .line 192
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "already download size "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-wide v6, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    invoke-virtual {v5, v6, v7}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    .line 197
    :goto_4
    const/4 v5, 0x1

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 205
    .end local v0           #conn:Ljava/net/HttpURLConnection;
    .end local v2           #fileSaveDir:Ljava/io/File;
    .end local v3           #i:I
    .end local v4           #url:Ljava/net/URL;
    :catch_0
    move-exception v1

    .line 206
    .local v1, e:Ljava/lang/Exception;
    invoke-virtual {v1}, Ljava/lang/Exception;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    .line 207
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    goto/16 :goto_0

    .line 183
    .end local v1           #e:Ljava/lang/Exception;
    .restart local v0       #conn:Ljava/net/HttpURLConnection;
    .restart local v2       #fileSaveDir:Ljava/io/File;
    .restart local v3       #i:I
    .restart local v4       #url:Ljava/net/URL;
    :cond_2
    :try_start_2
    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v6, v3, 0x1

    invoke-static {v6}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v6

    const-wide/16 v7, 0x0

    invoke-static {v7, v8}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v7

    invoke-interface {v5, v6, v7}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 182
    add-int/lit8 v3, v3, 0x1

    goto :goto_1

    .line 186
    :cond_3
    iget-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    iget-object v7, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v7, v7

    int-to-long v7, v7

    div-long/2addr v5, v7

    const-wide/16 v7, 0x1

    add-long/2addr v5, v7

    goto :goto_2

    .line 190
    :cond_4
    iget-wide v6, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v8, v3, 0x1

    invoke-static {v8}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v8

    invoke-interface {v5, v8}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/Long;

    invoke-virtual {v5}, Ljava/lang/Long;->longValue()J

    move-result-wide v8

    add-long v5, v6, v8

    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 189
    add-int/lit8 v3, v3, 0x1

    goto :goto_3

    .line 194
    :cond_5
    const-wide/16 v5, 0x0

    iput-wide v5, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    .line 195
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "already download size "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-wide v6, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    invoke-virtual {v5, v6, v7}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    goto :goto_4

    .line 202
    .end local v3           #i:I
    :cond_6
    const/4 v5, 0x0

    iput-boolean v5, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    goto/16 :goto_0
.end method

.method private getFileName(Ljava/net/HttpURLConnection;)Ljava/lang/String;
    .locals 7
    .parameter "conn"

    .prologue
    .line 228
    iget-object v4, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    iget-object v5, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    const/16 v6, 0x2f

    invoke-virtual {v5, v6}, Ljava/lang/String;->lastIndexOf(I)I

    move-result v5

    add-int/lit8 v5, v5, 0x1

    invoke-virtual {v4, v5}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    .line 229
    .local v0, filename:Ljava/lang/String;
    if-eqz v0, :cond_0

    const-string v4, ""

    invoke-virtual {v0}, Ljava/lang/String;->trim()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-eqz v4, :cond_1

    .line 230
    :cond_0
    const/4 v1, 0x0

    .line 231
    .local v1, i:I
    :goto_0
    invoke-virtual {p1, v1}, Ljava/net/HttpURLConnection;->getHeaderField(I)Ljava/lang/String;

    move-result-object v3

    .line 232
    .local v3, mine:Ljava/lang/String;
    if-nez v3, :cond_2

    .line 238
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, ".tmp"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .end local v1           #i:I
    .end local v3           #mine:Ljava/lang/String;
    :cond_1
    move-object v4, v0

    .line 240
    :goto_1
    return-object v4

    .line 233
    .restart local v1       #i:I
    .restart local v3       #mine:Ljava/lang/String;
    :cond_2
    const-string v4, "content-disposition"

    invoke-virtual {p1, v1}, Ljava/net/HttpURLConnection;->getHeaderFieldKey(I)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v4

    if-eqz v4, :cond_3

    .line 234
    const-string v4, ".*filename=(.*)"

    invoke-static {v4}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v4

    invoke-virtual {v3}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v2

    .line 235
    .local v2, m:Ljava/util/regex/Matcher;
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->find()Z

    move-result v4

    if-eqz v4, :cond_3

    const/4 v4, 0x1

    invoke-virtual {v2, v4}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v4

    goto :goto_1

    .line 230
    .end local v2           #m:Ljava/util/regex/Matcher;
    :cond_3
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public static getHttpResponseHeader(Ljava/net/HttpURLConnection;)Ljava/util/Map;
    .locals 4
    .parameter "http"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/net/HttpURLConnection;",
            ")",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    .prologue
    .line 335
    new-instance v0, Ljava/util/LinkedHashMap;

    invoke-direct {v0}, Ljava/util/LinkedHashMap;-><init>()V

    .line 336
    .local v0, header:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    const/4 v1, 0x0

    .line 337
    .local v1, i:I
    :goto_0
    invoke-virtual {p0, v1}, Ljava/net/HttpURLConnection;->getHeaderField(I)Ljava/lang/String;

    move-result-object v2

    .line 338
    .local v2, mine:Ljava/lang/String;
    if-nez v2, :cond_0

    .line 341
    return-object v0

    .line 339
    :cond_0
    invoke-virtual {p0, v1}, Ljava/net/HttpURLConnection;->getHeaderFieldKey(I)Ljava/lang/String;

    move-result-object v3

    invoke-interface {v0, v3, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 336
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public static main([Ljava/lang/String;)V
    .locals 0
    .parameter "args"

    .prologue
    .line 376
    return-void
.end method

.method private static print(Ljava/lang/String;)V
    .locals 1
    .parameter "msg"

    .prologue
    .line 356
    const-string v0, "FileDownloader"

    invoke-static {v0, p0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 357
    return-void
.end method

.method public static printResponseHeader(Ljava/net/HttpURLConnection;)V
    .locals 6
    .parameter "http"

    .prologue
    .line 348
    invoke-static {p0}, Lcom/netease/newsreader/download/FileDownloader;->getHttpResponseHeader(Ljava/net/HttpURLConnection;)Ljava/util/Map;

    move-result-object v1

    .line 349
    .local v1, header:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-interface {v1}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-nez v3, :cond_0

    .line 353
    return-void

    .line 349
    :cond_0
    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/Map$Entry;

    .line 350
    .local v0, entry:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v3

    if-eqz v3, :cond_1

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v5, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, ":"

    invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 351
    .local v2, key:Ljava/lang/String;
    :goto_1
    new-instance v5, Ljava/lang/StringBuilder;

    invoke-static {v2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v5, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    goto :goto_0

    .line 350
    .end local v2           #key:Ljava/lang/String;
    :cond_1
    const-string v2, ""

    goto :goto_1
.end method


# virtual methods
.method protected declared-synchronized append(I)V
    .locals 4
    .parameter "size"

    .prologue
    .line 74
    monitor-enter p0

    :try_start_0
    iget-wide v0, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    int-to-long v2, p1

    add-long/2addr v0, v2

    iput-wide v0, p0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 75
    monitor-exit p0

    return-void

    .line 74
    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public download(Lcom/netease/newsreader/download/DownloadProgressListener;)J
    .locals 18
    .parameter "listener"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 252
    :try_start_0
    new-instance v16, Ljava/io/RandomAccessFile;

    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->saveFile:Ljava/io/File;

    const-string v2, "rw"

    move-object/from16 v0, v16

    invoke-direct {v0, v1, v2}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 254
    .local v16, randOut:Ljava/io/RandomAccessFile;
    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    const-wide/16 v4, 0x0

    cmp-long v1, v1, v4

    if-lez v1, :cond_0

    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    move-object/from16 v0, v16

    invoke-virtual {v0, v1, v2}, Ljava/io/RandomAccessFile;->setLength(J)V

    .line 255
    :cond_0
    invoke-virtual/range {v16 .. v16}, Ljava/io/RandomAccessFile;->close()V

    .line 256
    new-instance v3, Ljava/net/URL;

    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->downloadUrl:Ljava/lang/String;

    invoke-direct {v3, v1}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 257
    .local v3, url:Ljava/net/URL;
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    invoke-interface {v1}, Ljava/util/Map;->size()I

    move-result v1

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v2, v2

    if-eq v1, v2, :cond_1

    .line 258
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    invoke-interface {v1}, Ljava/util/Map;->clear()V

    .line 259
    const/4 v13, 0x0

    .local v13, i:I
    :goto_0
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v1, v1

    if-lt v13, v1, :cond_4

    .line 263
    .end local v13           #i:I
    :cond_1
    const/4 v13, 0x0

    .restart local v13       #i:I
    :goto_1
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v1, v1

    if-lt v13, v1, :cond_5

    .line 274
    const/4 v14, 0x1

    .line 276
    .local v14, notFinish:Z
    :goto_2
    if-eqz v14, :cond_2

    move-object/from16 v0, p0

    iget-boolean v1, v0, Lcom/netease/newsreader/download/FileDownloader;->pause:Z

    if-eqz v1, :cond_8

    .line 306
    :cond_2
    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    move-object/from16 v0, p0

    iget-wide v4, v0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    cmp-long v1, v1, v4

    if-eqz v1, :cond_3

    .line 315
    move-object/from16 v0, p0

    iget-boolean v1, v0, Lcom/netease/newsreader/download/FileDownloader;->pause:Z

    if-nez v1, :cond_3

    .line 316
    if-eqz p1, :cond_3

    const-string v1, "error"

    move-object/from16 v0, p1

    invoke-interface {v0, v1}, Lcom/netease/newsreader/download/DownloadProgressListener;->onErrorListener(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 327
    :cond_3
    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    return-wide v1

    .line 260
    .end local v14           #notFinish:Z
    :cond_4
    :try_start_1
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v2, v13, 0x1

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    const-wide/16 v4, 0x0

    invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v4

    invoke-interface {v1, v2, v4}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 259
    add-int/lit8 v13, v13, 0x1

    goto :goto_0

    .line 264
    :cond_5
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v2, v13, 0x1

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-interface {v1, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Long;

    invoke-virtual {v1}, Ljava/lang/Long;->longValue()J

    move-result-wide v10

    .line 265
    .local v10, downLength:J
    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->block:J

    cmp-long v1, v10, v1

    if-gez v1, :cond_6

    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    move-object/from16 v0, p0

    iget-wide v4, v0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    cmp-long v1, v1, v4

    if-gez v1, :cond_6

    .line 266
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    move-object/from16 v17, v0

    new-instance v1, Lcom/netease/newsreader/download/DownloadThread;

    move-object/from16 v0, p0

    iget-object v4, v0, Lcom/netease/newsreader/download/FileDownloader;->saveFile:Ljava/io/File;

    move-object/from16 v0, p0

    iget-wide v5, v0, Lcom/netease/newsreader/download/FileDownloader;->block:J

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v7, v13, 0x1

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-interface {v2, v7}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/Long;

    invoke-virtual {v2}, Ljava/lang/Long;->longValue()J

    move-result-wide v7

    add-int/lit8 v9, v13, 0x1

    move-object/from16 v2, p0

    invoke-direct/range {v1 .. v9}, Lcom/netease/newsreader/download/DownloadThread;-><init>(Lcom/netease/newsreader/download/FileDownloader;Ljava/net/URL;Ljava/io/File;JJI)V

    aput-object v1, v17, v13

    .line 267
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    const/4 v2, 0x7

    invoke-virtual {v1, v2}, Lcom/netease/newsreader/download/DownloadThread;->setPriority(I)V

    .line 268
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    invoke-virtual {v1}, Lcom/netease/newsreader/download/DownloadThread;->start()V

    .line 263
    :goto_3
    add-int/lit8 v13, v13, 0x1

    goto/16 :goto_1

    .line 270
    :cond_6
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    const/4 v2, 0x0

    aput-object v2, v1, v13
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_3

    .line 321
    .end local v3           #url:Ljava/net/URL;
    .end local v10           #downLength:J
    .end local v13           #i:I
    .end local v16           #randOut:Ljava/io/RandomAccessFile;
    :catch_0
    move-exception v12

    .line 322
    .local v12, e:Ljava/lang/Exception;
    invoke-virtual {v12}, Ljava/lang/Exception;->printStackTrace()V

    .line 323
    if-eqz p1, :cond_7

    invoke-virtual {v12}, Ljava/lang/Exception;->toString()Ljava/lang/String;

    move-result-object v1

    move-object/from16 v0, p1

    invoke-interface {v0, v1}, Lcom/netease/newsreader/download/DownloadProgressListener;->onErrorListener(Ljava/lang/String;)V

    .line 324
    :cond_7
    invoke-virtual {v12}, Ljava/lang/Exception;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Lcom/netease/newsreader/download/FileDownloader;->print(Ljava/lang/String;)V

    .line 325
    new-instance v1, Ljava/lang/Exception;

    const-string v2, "file download fail"

    invoke-direct {v1, v2}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V

    throw v1

    .line 277
    .end local v12           #e:Ljava/lang/Exception;
    .restart local v3       #url:Ljava/net/URL;
    .restart local v13       #i:I
    .restart local v14       #notFinish:Z
    .restart local v16       #randOut:Ljava/io/RandomAccessFile;
    :cond_8
    const/4 v14, 0x0

    .line 278
    const-wide/16 v1, 0x64

    :try_start_2
    invoke-static {v1, v2}, Ljava/lang/Thread;->sleep(J)V

    .line 279
    const/4 v15, 0x0

    .line 280
    .local v15, num:I
    const/4 v13, 0x0

    :goto_4
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v1, v1

    if-lt v13, v1, :cond_a

    .line 298
    if-eqz v14, :cond_9

    if-eqz p1, :cond_9

    move-object/from16 v0, p0

    iget-wide v1, v0, Lcom/netease/newsreader/download/FileDownloader;->downloadSize:J

    move-object/from16 v0, p1

    invoke-interface {v0, v1, v2}, Lcom/netease/newsreader/download/DownloadProgressListener;->onDownloadSize(J)V

    .line 299
    :cond_9
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v1, v1

    if-ne v15, v1, :cond_d

    .line 300
    const/4 v14, 0x0

    goto/16 :goto_2

    .line 282
    :cond_a
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    if-eqz v1, :cond_b

    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    invoke-virtual {v1}, Lcom/netease/newsreader/download/DownloadThread;->isFinish()Z

    move-result v1

    if-nez v1, :cond_b

    .line 283
    const/4 v14, 0x1

    .line 284
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    invoke-virtual {v1}, Lcom/netease/newsreader/download/DownloadThread;->getDownLength()J

    move-result-wide v1

    const-wide/16 v4, -0x1

    cmp-long v1, v1, v4

    if-nez v1, :cond_b

    .line 285
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    move-object/from16 v17, v0

    new-instance v1, Lcom/netease/newsreader/download/DownloadThread;

    move-object/from16 v0, p0

    iget-object v4, v0, Lcom/netease/newsreader/download/FileDownloader;->saveFile:Ljava/io/File;

    move-object/from16 v0, p0

    iget-wide v5, v0, Lcom/netease/newsreader/download/FileDownloader;->block:J

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    add-int/lit8 v7, v13, 0x1

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-interface {v2, v7}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/Long;

    invoke-virtual {v2}, Ljava/lang/Long;->longValue()J

    move-result-wide v7

    add-int/lit8 v9, v13, 0x1

    move-object/from16 v2, p0

    invoke-direct/range {v1 .. v9}, Lcom/netease/newsreader/download/DownloadThread;-><init>(Lcom/netease/newsreader/download/FileDownloader;Ljava/net/URL;Ljava/io/File;JJI)V

    aput-object v1, v17, v13

    .line 286
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    const/4 v2, 0x7

    invoke-virtual {v1, v2}, Lcom/netease/newsreader/download/DownloadThread;->setPriority(I)V

    .line 287
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v13

    invoke-virtual {v1}, Lcom/netease/newsreader/download/DownloadThread;->start()V
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    .line 288
    const/4 v14, 0x0

    .line 293
    :cond_b
    if-nez v14, :cond_c

    .line 294
    add-int/lit8 v15, v15, 0x1

    .line 280
    :cond_c
    add-int/lit8 v13, v13, 0x1

    goto/16 :goto_4

    .line 302
    :cond_d
    const/4 v14, 0x1

    goto/16 :goto_2
.end method

.method public getFileSize()J
    .locals 2

    .prologue
    .line 67
    iget-wide v0, p0, Lcom/netease/newsreader/download/FileDownloader;->fileSize:J

    return-wide v0
.end method

.method public getThreadSize()I
    .locals 1

    .prologue
    .line 60
    iget-object v0, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v0, v0

    return v0
.end method

.method public getThreads()[Lcom/netease/newsreader/download/DownloadThread;
    .locals 1

    .prologue
    .line 360
    iget-object v0, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    return-object v0
.end method

.method public initStatus()Z
    .locals 1

    .prologue
    .line 54
    iget-boolean v0, p0, Lcom/netease/newsreader/download/FileDownloader;->init:Z

    return v0
.end method

.method public isNetworkerr()Z
    .locals 1

    .prologue
    .line 51
    iget-boolean v0, p0, Lcom/netease/newsreader/download/FileDownloader;->networkerr:Z

    return v0
.end method

.method public pause()V
    .locals 2

    .prologue
    .line 215
    const/4 v0, 0x0

    .local v0, index:I
    :goto_0
    iget-object v1, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    if-eqz v1, :cond_0

    iget-object v1, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    array-length v1, v1

    if-lt v0, v1, :cond_1

    .line 221
    :cond_0
    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/netease/newsreader/download/FileDownloader;->pause:Z

    .line 222
    return-void

    .line 216
    :cond_1
    iget-object v1, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v0

    if-eqz v1, :cond_2

    .line 217
    iget-object v1, p0, Lcom/netease/newsreader/download/FileDownloader;->threads:[Lcom/netease/newsreader/download/DownloadThread;

    aget-object v1, v1, v0

    invoke-virtual {v1}, Lcom/netease/newsreader/download/DownloadThread;->pause()V

    .line 215
    :cond_2
    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method protected update(IJ)V
    .locals 3
    .parameter "threadId"
    .parameter "pos"

    .prologue
    .line 82
    iget-object v0, p0, Lcom/netease/newsreader/download/FileDownloader;->data:Ljava/util/Map;

    invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-static {p2, p3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    invoke-interface {v0, v1, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 83
    return-void
.end method
